package defaultPackage;
import java.util.ArrayList;
import java.util.Random;


public class EventHandler 
{
	private static final Random rand = new Random();
	public static boolean active = false;
	ArrayList<Event> events = new ArrayList<Event>();
	public void update(MainClass main)
	{
		if(active)
		{
			if(rand.nextInt(TestEvent.probibility)==0)	
			{
				events.add(new TestEvent());
				events.get(events.size()-1).init(main);
			}
		}
		
		for(Event e:events)
		{
			e.update(main);
		}
		for(int i = 0;i<events.size();i++)
		{
			if(events.get(i).isDone())
			{
				events.remove(i);
				i--;
			}
		}
	}
}
